package gqz.mvvm.Test;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import gqz.mvvm.R;

/**
 * Created by Administrator on 2018/3/21.
 */

public class ActivityB extends Activity implements View.OnClickListener {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_b);

        TextView tv = (TextView) findViewById(R.id.test_activityb_tv);
        Button btn = (Button) findViewById(R.id.test_activityb_btn);
        btn.setOnClickListener(this);

        Intent i = getIntent();
        tv.setText("data=" + i.getStringExtra("data"));
    }

    @Override
    public void onClick(View v) {
        Intent i = new Intent();
        i.putExtra("data", "activity B");
        setResult(Activity.RESULT_OK, i);
        finish();
    }
}
